<#import "/spring.ftl" as spring/>
<#import "html-macro.ftl" as h />
<#import "declaration-macro.ftl" as d />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>${d.declarationTypeName__}
        下单页面${d.isGeneralTrade__?string("---一般贸易",(d.isProcessTrade__?string("---加工贸易","---特殊贸易")))}</title>
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/awesome/css/font-awesome.min.css" />"/>
<#--<link rel="stylesheet" type="text/css" href="<@spring.url "/semantic/semantic.css" />">-->
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/button.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/dropdown.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/form.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/grid.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/icon.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/input.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/item.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/label.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/loader.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/menu.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/message.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/reset.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/search.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/segment.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/tab.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/table.min.css" />">
    <link rel="stylesheet" type="text/css"
          href="<@spring.url "/semantic/components/transition.min.css" />">
    <link rel="stylesheet" type="text/css" href="<@spring.url "/layer/skin/layer.css" />">
    <link rel="stylesheet" type="text/css" href="<@spring.url "/css/order.css" />">
    <script type="text/javascript" src="<@spring.url "/jquery-3.1.1.min.js" />"></script>
    <script type="text/javascript" src="<@spring.url "/jquery.extend.js" />"></script>
<#--<script type="text/javascript" src="<@spring.url "/semantic/semantic.js" />"></script>-->
    <script type="text/javascript"
            src="<@spring.url "/semantic/components/form0.min.js" />"></script>
    <script type="text/javascript"
            src="<@spring.url "/semantic/components/checkbox.min.js" />"></script>
    <script type="text/javascript"
            src="<@spring.url "/semantic/components/tab.min.js" />"></script>
    <script type="text/javascript"
            src="<@spring.url "/semantic/components/api.min.js" />"></script>
    <script type="text/javascript"
            src="<@spring.url "/semantic/components/transition.min.js" />"></script>
    <script type="text/javascript"
            src="<@spring.url "/semantic/components/dropdown0.min.js" />"></script>
    <script type="text/javascript" src="<@spring.url "/js/form/jquery.form.min.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/layer/layer.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/data-type.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/dropdown.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/dropdown-data.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/init.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/My97DatePicker/WdatePicker.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/declaration.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/js/queryAndUseModel.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/declarationJumpConfig.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/elementJump.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/js/jquery.AjaxPlugin.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/js/layout.js"/>"></script>
    <script type="text/javascript" src="<@spring.url "/js/order.js"/>"></script>
<#--<script type="text/javascript" src="<@spring.url "/js/require.js"/>"
        data-main="<@spring.url "/js/main.js"/>" defer async="true"></script>-->
    <script type="text/javascript">
        var XLSX = {};
        $(document).ready(function () {
        <#if h.readMode__>
            readMode_readGoods_bind(); //绑定只读页面商品的查看
        </#if>
        })
        ;
    </script>
</head>
<body>
<#if !d.isInsertPage__>
<div id="declaration_tabs" class="ui pointing secondary menu">
    <a class="active item" data-tab="first">报关单基础信息</a>
<#--/business/business-declaration.do?id=f0fc943257a8660c0157a87155e30018-->
    <a class="item" data-tab="business-declaration">报关单</a>
<#--business/business-declarationPackingList.do?editType=1&id=f0fc943257a8660c0157a87155e30018-->
    <#if d.declarationType__>
        <a class="item" data-tab="business-declarationPackingList">装箱单</a>
    <#--/business/business-declarationContract.do?id=f0fc943257a8660c0157a87155e30018-->
        <a class="item" data-tab="business-declarationContract">合同</a>
    <#--/business/business-declarationInvoice.do?id=f0fc943257a8660c0157a87155e30018-->
        <a class="item" data-tab="business-declarationInvoice">发票</a>
    </#if>
<#--http://219.130.222.62:7080/report/ReportServer?reportlet=gtimp/declarationPackingList_1.cpt&op=write&id=f0fc943257a8660c0157a87155e30018-->
    <a class="item" data-tab="business-declarationReport">导出报关资料</a>
</div>
<div class="ui active tab segment" data-tab="first">
</#if>
    <div class="ui grid " style="padding: 20px 20px">
    <#if h.readMode__>
    <#--只读模式-->
        <#include "test-order-button-read.ftl" />
    <#else >
        <#include "test-order-button.ftl" />
    </#if>
        <!--报关单主体信息-->
        <div class="ui eleven wide column">
        <#if d.declarationType__>
            <#include "test-order-Exportdeclaration.ftl" />
        <#else>
            <#include "test-order-Importdeclaration.ftl" />
        </#if>
        <#--<#include "test-order-declaration.ftl" />-->
        </div>
        <div class="five wide column">
        <#include  "test-order-container.ftl"/>
        </div>
        <div style="display: none;">
            <form id="declarationForm" method="post" action="<@spring.url "/order/save" />">
            </form>
        </div>
    </div>
<#if !d.isInsertPage__>
</div>
<div class="ui tab segment" data-tab="business-declaration">
    <iframe width="100%" height="100%" frameborder="0" scrolling="no"
            src="<@spring.url "/business/business-declaration"/>?id=${declaration.id}&v=3.0"></iframe>
</div>
    <#if d.declarationType__>
    <div class="ui tab segment" data-tab="business-declarationPackingList">
        <iframe width="100%" height="100%" frameborder="0" scrolling="no"
                src="<@spring.url "/business/business-declarationPackingList"/>?id=${declaration.id}&v=3.0"></iframe>
    </div>
    <div class="ui tab segment" data-tab="business-declarationContract">
        <iframe width="100%" height="100%" frameborder="0" scrolling="no"
                src="<@spring.url "/business/business-declarationContract"/>?id=${declaration.id}&v=3.0"></iframe>
    </div>
    <div class="ui tab segment" data-tab="business-declarationInvoice">
        <iframe width="100%" height="100%" frameborder="0" scrolling="no"
                src="<@spring.url "/business/business-declarationInvoice"/>?id=${declaration.id}&v=3.0"></iframe>
    </div>
    </#if>
<div class="ui tab segment" data-tab="business-declarationReport">
    <iframe width="100%" height="800px" frameborder="0" scrolling="no"
            src="http://219.130.222.62:7080/report/ReportServer?reportlet=gtimp/declarationPackingList_178test_.cpt&op=write&id=${declaration.id}"></iframe>
</div>
</#if>
</body>
<script type="text/javascript">
    var beforeSubmitValidate;
    $(document).ready(function () {
        var onlyFormatValid = function () {
            $('.ui.allform').form(validationRules['allFormFormatRule']);
            $(".ui.topform").form(validationRules.topFormRule);
            var allValidBoo = $('.ui.allform').form('is valid');
            var topValidBoo = $(".ui.topform").form('is valid');
            if (allValidBoo && topValidBoo) {
                return true;
            } else {
                return false;
            }
        };
        var $form = $("#declarationForm");
        /*暂存按钮*/
        $("#saveBtn").click(function () {
            /*if (onlyFormatValid()) {*/
            $form.unbind('submit');
            $(this).addDisabledClass();
            $form.submit(function () {
                $(this).append($("input").filter(function () {
                    var name = $(this).attr("name");
                    return !(name == undefined || name == "" || /^0.+/.test(name));
                }).clone());
                $(this).ajaxSubmit(
                        {
                            type: 'post', // 提交方式 get/post
                            url: '<@spring.url "/order/save" />', // 需要提交的 url
                            /*beforeSubmit: beforeSubmitValidate,*/
                            success: function (data) { // data 保存提交后返回的数据，一般为 json 数据
                                // 此处可对 data 作相关处理
                                console.log(data);
                                var tipMsg;
                                if (data.result == true) {
                                    tipMsg = data.msg;
                                    layer.alert(tipMsg, function (index) {
                                        layer.close(index);
                                    <#if d.isInsertPage__>
                                        location.href =
                                        "<@spring.url "/order/update?id=" />"
                                        + data.data;
                                    <#else>
                                        var sliceLen = $.fn.order.isExport ? 4 : 2;
                                        var $iframes = $("iframe").slice(0, sliceLen);
                                        $.each($iframes, function (i, n) {
                                            n.contentWindow.location.reload();
                                        });
                                    </#if>
                                    });
                                } else {
                                    tipMsg = data.msg + "<br/>错误原因：" + data.data;
                                    layer.alert(tipMsg);
                                }
                                //$(this).resetForm(); // 提交后重置表单
                                $("#saveBtn").removeDisabledClass();
                            }
                        });
                $form.empty();
                return false;
            });
            $form.submit();
            /*} else {
                return false;
            }*/

        });

    });
</script>
</html>
